package cn.swust.score.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component; 
import cn.swust.score.pojo.Rater;
@Component
public class CustomUserService implements UserDetailsService {

	@Autowired
	RaterService raterServer;
	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		 
		Rater user = raterServer.getByName(username) ;
		 
	        if (user == null) {
	            throw new UsernameNotFoundException("用户名不存在");
	        }
	        System.out.println("s:"+user.getName());
	        System.out.println("username:"+user.getUsername()+";password:"+user.getPassword());
	        return user;
		 
	}

}
